<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>EHS发布供求信息</title>
    <link href="__TMPL__/style/common.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="__TMPL__/style/supply-style.css" rel="stylesheet" type="text/css" media="screen" />
    <link  href="__ROOT__/Public/js/easyvalidator/css/validate.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="__ROOT__/Public/Js/jquery-1.5.0.min.js"></script>
    <script type="text/javascript" src="__ROOT__/Public/Js/core.js"></script>
    <script charset="utf-8" src="__TMPL__/js/editor/kindeditor.js"></script>
    <script type="text/javascript" src="__ROOT__/Public/js/easyvalidator/js/easy_validator.pack.js"></script>
    <script type="text/javascript" src="__ROOT__/Public/js/easyvalidator/js/jquery.bgiframe.min.js"></script>
    <script type="text/javascript" src="__ROOT__/Public/Js/WdatePicker.js"></script>
  </head>
  <body>
    <layout name="Public:header" cache="0" />
    <div class="container">
      <div class="path-sub-nav">您所在位置：<a href="/index.html">首页</a> &gt; <a href="__URL__/index/">供求</a> &gt; <if condition="$edit neq 0">编辑供求信息<else/>发布供求信息</if></div>
      <div class="mode-info-publish">
        <form id="frmPublish" action="__URL__/save" method="post" enctype="multipart/form-data">
		 <input name="id" type="hidden" value="{$edit}" />
          <label><span>*信息标题：</span>
            <input name="title" type="text" style="width:400px;" reg="^.+$" tip="1-60个字节" maxlength="30" value="{$info.title}"/>
          </label>
          <label><span>*选择地区：</span>
            <select onchange="changeRegion(this)" style="width:150px">
              <volist name="region_level_1" id="vo">
                <option value="{$vo.id}" <if condition="$vo.id eq $region_id"> selected</if>>{$vo.title}</option>
              </volist>
            </select>
            <select name="dq_id">
              <volist name="region_level_2" id="vo">
                <option value="{$vo.id}" <if condition="$vo.id eq $region_id2">selected</if>>{$vo.title}</option>
              </volist>
            </select>
          </label>
          <label><span>*信息类别：</span>
            <select id="selType" name="type" style="width:150px" onchange="changeType(this)">
              <option value="1">会务</option>
              <option value="3">培训</option>
              <option value="5" selected>招聘求职</option>
              <option value="7">EHS需求</option>
            </select>
            <select name="sub">
              <option value="1">招聘</option>
              <option value="2">求职</option>
            </select>
          </label>
          <div style="width:960px;margin:5px auto;line-height:20px;vertical-align:middle;color:red;text-decoration:underline">发布说明：<br />
		  1、用户可以免费在EHS.CN中发布企业培训、供求信息；<br />
		  2、用户发布的信息需经过EHS.CN审核才能在供求页面显示；<br />
		  3、请在本页内填写你的个人联系信息、信息的分类、信息的详细内容和相应的附件（必要时）；<br />
		  4、避免信息出现不必要的错乱，请避免从word等文档中复制表格等格式的内容进行发布，建议用页面提供的编辑器进行编辑或者在附件中上传你的表格内容</div>
		  <div><textarea id="textContent" name="content" style="width:940px;height:400px; font-size:14px; padding: 0;">{$info.content}</textarea></div>
		  
		  <if condition="$attach neq null">
		    <label><span>已传附件</span>
			   <ul>
			   <volist name='attach' id='item'>
			   <li id="li_{$item.id}">{$item.file_name}&nbsp;&nbsp;&nbsp;<span id="attach_{$item.id}"><a href="#"  onclick="return delAttach({$item.id});">删除</a></span></li>
			   </volist>
			   </ul>
			</label>
		  </if>
		  <label><span>上传附件：</span>		  		  
		  <input name="file" type="file" size="30" /><br /><span style="color:#999">请上传不大于1M大小的，gif/jpg/png/doc/docx/pdf/xls/xlsx/rar/zip/pdf等格式的图片或者文档</span>
		  </label>
		  
          <div class="supply-contact">
            <h3>联系方式</h3>
            <label><span>*联 系 人：</span>
              <input name="linkman" type="text" reg="^.+$" tip="请输入联系人名称" value="{$info.linkman}"/></label>
            <label><span>*联 系 电 话：</span>
              <input name="phone" type="text"  value="{$info.phone}"/></label>
            <label><span>*有 效 期 限：</span>
              <input name="stop_date" class="Wdate" type="text" size="14" maxlength="10" value="{$info.stop_date}" onClick="WdatePicker()"/>
            </label>
            <p>有“<span style="padding:0; color:#d55530;">*</span>”的项目必须填写！发布后需管理员审核，请认真填写需求信息。</p>
            <div class="btn-info_publish">
              <center>
                <input type="submit" onclick="return checkForm();" value="保存" /> &nbsp;
                <input type="reset" value="重填" />
              </center>
            </div>
          </div>
        </form>
      </div>
    </div>
    <layout name="Public:footer" cache="0" />
    <script>
      var url = '__URL__';
      init();
      function init(){
        KE.show({
          id : 'textContent',
		  resizeMode : 1,
          items:[ 'justifyleft', 'justifycenter', 'justifyright','justifyfull','|','paste','plainpaste', 'wordpaste', '|','title', 'fontname', 'fontsize',
            '|', 'textcolor', 'bgcolor', 'bold','italic', 'underline','|','link', 'unlink','|','emoticons']
        });
        $("#frmPublish").find('select[name=type]').val("{$type}");
        changeType($("#frmPublish").find('select[name=type]'));
        $("#frmPublish").find('select[name=sub]').val("{$sub}");
      }
	 KE.html('textContent',"{$info.content}")
      //改变地区下拉框
      function changeRegion(self){
        var id = $(self).val();
        var data = {id:id};
        ajax.send(url+'/ajaxChgRegion',data,function(obj){
          var data = obj.data;
          $(self).next('select').html(_getHTMLRegion(data));
        });
      }
      //画二级地区的select
      function _getHTMLRegion(list){
        var str = [], p = 0;
        for (var i in list){
          var l = list[i];
          str[p++] = '<option value="'+l.id+'">'+l.title+'</option>';
        }
        return str.join('');
      }
      //改变类型下拉框
      function changeType(self){
        var type = $(self).val();
        var strs = {
          1: '<option value=0></option>',
          3: '<option value=0></option>',
          5: '<option value=1>招聘</option><option value=2>求职</option>',
          7: '<option value=1>产品</option><option value=2>EHS服务</option><option value=3>工程</option><option value=4>悬赏或招标</option>'
        };
        var hidden = type < 5 ? '.hide()' : '.show()';
        eval('$(self).next("select").html("'+strs[type]+'")'+hidden);
      }
      //表单提交前检查
      function checkForm(){
        //不能为空
        var tips = {
          1:{type:'input',name:'title',tip:'请输入标题'},
          2:{type:'textarea',name:'content',tip:'请输入内容'},
          3:{type:'input',name:'linkman',tip:'请输入联系人'},
          4:{type:'input',name:'phone',tip:'请输入联系电话'},
          5:{type:'input',name:'stop_date',tip:'请选择日期'}
        };
        for (var i in tips) {
          var t = tips[i];
          if ($("#frmPublish").find(t.type+'[name='+t.name+']').val() == '') {
            alert(t.tip);
            return false;
          }
        }
        /*if ($("#frmPublish").find('input[name=phone]').val().length <7) {
          alert("输入的联系电话格式有错");
          return false;
        }*/
      }
	  
	  function delAttach(id){
	     $.getJSON('__URL__/delAttachAjax/id/'+id,function(data){
		   if(data.result==1){
		      $('#li_'+id).css('color','#999');
		      $('#attach_'+id).html('已删除');
			 }
		   else alert('操作失败，请稍候再试');
		 });	
		 return false;  
	  }
      
    </script>
  </body>
</html>
